import avatars from "./imgs/avatars.js"
import Mock from 'mockjs'

const randomTwentyImg = () => {
    const imgList = []
    const ranCount = Math.ceil(Math.random() * 20)
    for(let j = 0; j<ranCount;j++) {
        imgList.push(avatars[Math.floor(Math.random() * 60)])
    }
    return imgList
}

const randomNames = () => {
    const names = []
    const ranCount = Math.floor(Math.random() * 5)
    for(let j = 0; j<ranCount;j++) {
        names.push(Mock.Random.cname())
    }
    return names
}


// 获取朋友圈动态
export const getMomentList = (start = 10, pos = 20) => {
    const count = pos - start // 当前返回多少条数据
    const momentList = []
    for (let i = 0; i < count; i++) {
        if(i==0) { // 纯文字 自己发的
            momentList.push({
                id: start + i,
                type: 0,
                content: Mock.Random.csentence(),
                time: Mock.Random.date('hh:mm'),
                imgList: [],
                likeList: randomNames(),
                comment: 2,
                share: 1,
                publishUser: {
                    username: '你的头发乱了哦',
                    actvator: '',
                },
                commentList: [
                    {
                        id: Mock.Random.string('lower', 10),
                        publishName: '你的头发乱了哦',
                        replyName: '',
                        content: '卧槽真帅！'
                    },
                    {
                        id: Mock.Random.string('lower', 10),
                        publishName: Mock.Random.cname(),
                        replyName: '你的头发乱了哦',
                        content: '那可不！我是谁！'
                    },
                ]
            })
        } else {
            if(i%2===0) {
                momentList.push({
                    id: start + i,
                    type: 1,
                    content: Mock.Random.csentence(),
                    time: Mock.Random.date('hh:mm'),
                    imgList: [avatars[Math.floor(Math.random() * 61)]],
                    likeList: randomNames(),
                    comment: 2,
                    share: 1,
                    publishUser: {
                        username: Mock.Random.cname(),
                        actvator: avatars[Math.floor(Math.random() * 61)],
                    },
                    commentList: [
                        {
                            id: Mock.Random.string('lower', 10),
                            publishName: Mock.Random.cname(),
                            replyName: '',
                            content: '真帅！'
                        },
                        {
                            id: Mock.Random.string('lower', 10),
                            publishName: Mock.Random.cname(),
                            replyName: '',
                            content: '碉堡啦'
                        },
                        {
                            id: Mock.Random.string('lower', 10),
                            publishName: Mock.Random.cname(),
                            replyName: '',
                            content: '举头望明月！低头思故乡！'
                        },
                    ]
                })
            } else {
                momentList.push({
                    id: start + i,
                    type: 1,
                    content: Mock.Random.csentence(),
                    time: Mock.Random.date('hh:mm'),
                    imgList: randomTwentyImg(),
                    likeList: randomNames(),
                    comment: 2,
                    share: 1,
                    publishUser: {
                        username: Mock.Random.cname(),
                        actvator: avatars[Math.floor(Math.random() * 61)],
                    },
                    commentList: [
                        {
                            id: Mock.Random.string('lower', 10),
                            publishName: Mock.Random.cname(),
                            replyName: '',
                            content: Mock.Random.csentence()
                        },
                    ]
                })
            }
            
        }
    }
    return momentList
}